package com.sky.renren.control;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;

import com.renren.api.connect.android.Renren;
import com.renren.api.connect.android.exception.RenrenAuthError;
import com.renren.api.connect.android.view.RenrenAuthListener;
import com.renren.api.connect.android.view.RenrenDialogListener;
import com.sky.renren.activity.SplashActivity;
import com.sky.renren.library.CallbackInterface;

public class LoginController implements RenrenAuthListener, CallbackInterface{

	private static final String API_KEY = "6b1016db20c540e78bd1b20be4c707a3";
	private static final String SECRET_KEY = "4723a695c09e4ddebbe8d87393d95fb4";
	private static final String APP_ID = "105381";
	
	private Renren renren;
	private Context context;
	private String url;
	private RenrenDialogListener listener;
	
	public LoginController(Context context) {
		this.context = context;
		renren = new Renren(API_KEY, SECRET_KEY, APP_ID, context);
	}
	
	public void loadWeb() {
		renren.authorize((Activity)context, this, this);
	}
	@Override
	public void onComplete(Bundle values) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onRenrenAuthError(RenrenAuthError renrenAuthError) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onCancelLogin() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onCancelAuth(Bundle values) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onCallBack(String url, RenrenDialogListener listener) {
		this.url = url;
		this.listener = listener;
		((SplashActivity)this.context).loadWeb(this.url);
	}

}
